from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, sessionmaker

# 申明基类对象
Base = declarative_base()


# sqlite连接初始化
class SqliteSqlalchemy(object):
    def __init__(self):
        # 创建sqlite连接引擎
        engine = create_engine('sqlite:///./resources/db/data.db', echo=True)
        # 创建表
        Base.metadata.create_all(engine, checkfirst=True)
        # 创建sqlite的session连接对象
        self.session = sessionmaker(bind=engine)()
